package com.biu.billiards.controller;


import com.biu.billiards.model.vo.OpenDoor.AddOpenDoorVo;
import com.biu.billiards.model.vo.OpenDoor.GetOpenDoorVo;
import com.biu.billiards.model.vo.OpenDoor.UpdateOpenDoorVO;
import com.biu.billiards.model.vo.user.AddUserVo;
import com.biu.billiards.model.vo.user.GetUserVo;
import com.biu.billiards.model.vo.user.UpdateUserVO;
import com.biu.billiards.response.BaseResponse;
import com.biu.billiards.response.RespGenerator;
import com.biu.billiards.service.IDeviceService;
import com.biu.billiards.service.IOpenDoorService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author xue
 * @since 2023-11-08
 */
@RestController
@RequestMapping()
public class OpenDoorController {

    @Resource
    private IOpenDoorService openDoorService;



    @ApiOperation(value = "获取门禁数据")
    @PostMapping("/getOpenDoorPage")
    public BaseResponse<Map<String,Object>> getOpenDoorPage(@RequestBody GetOpenDoorVo getUserVo) {
        return RespGenerator.returnOK(openDoorService.getOpenDoorPage(getUserVo));
    }


    @ApiOperation(value = "修改门禁信息")
    @PutMapping("/updateOpenDoor")
    public BaseResponse<Boolean> updateOpenDoor(@RequestBody UpdateOpenDoorVO updateUserVO) {
        return RespGenerator.returnOK(openDoorService.updateOpenDoor(updateUserVO));
    }


    @ApiOperation(value = "新增门禁信息")
    @PostMapping("/addOpenDoor")
    public BaseResponse<Boolean> addOpenDoor(@RequestBody AddOpenDoorVo addUserVo) {
        return RespGenerator.returnOK(openDoorService.addOpenDoor(addUserVo));
    }


    @ApiOperation(value = "删除门禁信息")
    @DeleteMapping("/deleteOpenDoor")
    public BaseResponse<Boolean> deleteOpenDoor(@RequestParam("openId") Integer openId) {
        return RespGenerator.returnOK(openDoorService.deleteOpenDoor(openId));
    }











}
